import Vue from "vue";
import App from "./App.vue";
import { store } from "./store"; // 引入 store
import router from "./router";
import ElementUI from "element-ui";
import Echarts from "vue-echarts";

import * as echarts from "echarts";

import "@/style/index.scss";
import "./mock/index.js";
import axios from "axios";
import "normalize.css/normalize.css";
import "./assets/fonts/fonts.css";
import "./assets/fonts/iconfont.css";
import Vant from "vant";
import "vant/lib/index.css";
import Moment from "moment";

Vue.prototype.moment = Moment;
Vue.prototype.$echarts = echarts;
Vue.use(ElementUI);
Vue.prototype.$http = axios;
Vue.component("v-chart", Echarts);
Vue.config.productionTip = false;
Vue.use(Vant);

// 获取主题设置
const useCustomTheme = store.state.theme.useCustomTheme; // 从 Vuex 获取主题状态

if (useCustomTheme) {
  import("../src/theme/index.css")
    .then(() => {
      console.log("Custom theme loaded");
    })
    .catch((err) => {
      console.error("Error loading custom theme:", err);
    });
} else {
  import("element-ui/lib/theme-chalk/index.css")
    .then(() => {
      console.log("Default theme loaded");
    })
    .catch((err) => {
      console.error("Error loading default theme:", err);
    });
}

new Vue({
  render: (h) => h(App),
  router,
  store, // 注册 store
}).$mount("#app");
